<template>
  <Card>
    <div class="flexCSB">
      <Button type="primary" @click="create">新增场馆</Button>
      <div style="display: flex">
          <el-select
          v-model="caption.pushSwitch"
          @change="getAppMuseums"
          placeholder="请选择是否开启消息推送"
          style="width: 200px; margin-right: 10px"
        >
          <el-option :value="true" label="已开启消息推送"> 已开启消息推送 </el-option>
          <el-option :value="false" label="未开启消息推送"> 未开启消息推送 </el-option>
           <el-option value="" label="全部"> 全部 </el-option>
        </el-select>
        <Cascader
          style="width: 200px"
          :data="data2"
          trigger="hover"
          @on-change="change2"
          v-model="cascaderValue"
          placeholder="请选择地区"
        />
        <label>
          <Input
            v-model="museumName"
            @on-change="change"
            suffix="ios-search"
            style="width: 200px; margin-left: 10px"
            placeholder="请输入场馆名称"
          />
        </label>
        <!--   就是说这个是已入住和未入住    -->
        <el-select
          v-model="caption.isSettle"
          @change="getAppMuseums"
          placeholder="请选择是否入驻"
          style="width: 200px; margin-left: 10px"
        >
          <el-option :value="true" label="已入驻"> 已入驻 </el-option>
          <el-option :value="false" label="未入驻"> 未入驻 </el-option>
        </el-select>
        <!--   这个是跳转方式    -->
        <el-select
          v-model="caption.jumpType"
          @change="getAppMuseums"
          placeholder="请选择跳转方式"
          style="width: 200px; margin-left: 10px"
        >
          <el-option value="1" label="文旅平台"> 文旅平台 </el-option>
          <el-option value="2" label="小程序"> 小程序 </el-option>
          <el-option value="3" label="网页"> 网页 </el-option>
        </el-select>
      </div>
    </div>
    <Table
      class="table"
      :loading="loading1"
      highlight-row
      :columns="columns"
      :data="data1"
    />
    <Page
    show-total
      class="page"
      :total="total"
      :current.sync="current"
      show-elevator
      @on-change="changePage"
    />
    <Modal title="操作" v-model="modal" width="70">
      <Form ref="form" :model="newData" :label-width="120">
        <FormItem label="场馆名称：">
          <Input v-model="newData.name" placeholder="请输入场馆名称" />
        </FormItem>
        <FormItem label="场馆类型：">
          <RadioGroup v-model="newData.type" type="button">
            <Radio label="红色场馆"></Radio>
            <Radio label="文史类场馆"></Radio>
            <Radio label="自然馆"></Radio>
            <Radio label="科技馆"></Radio>
            <Radio label="图书档案馆"></Radio>
            <Radio label="景区"></Radio>
            <Radio label="其他"></Radio>
          </RadioGroup>
        </FormItem>
        <FormItem label="场馆城市：">
          <Cascader :data="data2" v-model="cascaderValue" trigger="hover" />
        </FormItem>
        <FormItem label="详细地址：">
          <div @click="dialogVisible = true">
            <Input
              v-model="address.detailAddress"
              readonly
              placeholder="请输入场馆名称搜索"
              style="display: inline-block"
            />
          </div>
          <!--  选择详细地址的弹框  -->
          <el-dialog
            :close-on-click-modal="false"
            title="详细地址"
            :visible.sync="dialogVisible"
            width="40%"
            @close="
              addreses = [];
              dagai = '';
            "
            :modal="false"
          >
            <div style="display: flex; margin-bottom: 20px">
              <Input
                v-model="dagai"
                placeholder="请输入场馆详细地址"
                style="display: inline-block"
              />
              <el-button
                style="margin-left: 20px; line-height: 0"
                type="success"
                plain
                @click="DetailedAddress"
                >搜索</el-button
              >
            </div>
            <el-table
              :data="addreses"
              :header-cell-style="{ textAlign: 'center' }"
              :cell-style="{ textAlign: 'center' }"
              style="width: 100%"
            >
              <el-table-column prop="name" label="地址名"> </el-table-column>
              <el-table-column prop="detailAddress" label="详细地址">
              </el-table-column>
              <el-table-column label="操作">
                <template slot-scope="scope">
                  <el-button
                    type="success"
                    size="mini"
                    @click="
                      address = scope.row;
                      dialogVisible = false;
                    "
                    >选择</el-button
                  >
                </template>
              </el-table-column>
            </el-table>
          </el-dialog>
        </FormItem>
        <FormItem label="场馆状态：">
          <el-select
            v-model="c_state"
            placeholder="请选择"
            style="display: block"
          >
            <el-option
              v-for="item in options"
              :key="item.label"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </FormItem>
        <FormItem label="预约方式：">
          <el-select
            v-model="reservationV"
            placeholder="请选择"
            style="display: block"
          >
            <el-option
              v-for="item in reservations"
              :key="item.label"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </FormItem>
        <!--   选择小程序预约配置    -->
        <template v-if="reservationV === 2">
          <FormItem label="小程序路径：">
            <Input
              v-model="wxInfo.wxPath"
              placeholder="请输入小程序路径"
              style="display: block"
            />
          </FormItem>
          <FormItem label="AppId：">
            <Input
              v-model="wxInfo.appid"
              placeholder="请输入小程序Appid"
              style="display: block"
            />
          </FormItem>
        </template>
        <!--   选择网页预约配置    -->
        <template v-if="reservationV === 3">
          <FormItem label="预约链接：">
            <Input
              v-model="h5Path"
              placeholder="网页的链接"
              style="display: block"
            />
          </FormItem>
        </template>

        <FormItem label="开闭馆时间">
          <Input
            placeholder="开馆时间(例如:09:00)"
            v-model="newData.arrivald1"
            style="width: 200px"
            clearable
          ></Input>
          <Input
            placeholder="停止入馆时间(例如:16:00)"
            v-model="newData.arrivald2"
            style="width: 200px"
            clearable
          ></Input>
          <Input
            placeholder="闭馆时间(例如:17:00)"
            v-model="newData.arrivald3"
            style="width: 200px"
            clearable
          ></Input>
        </FormItem>

        <FormItem label="开放信息：">
          <Input
            v-model="playTime"
            placeholder="请输入开放时间 类似于09:00-16:00 （周六、周日闭馆）此处仅作展示用途"
            style="display: block"
          />
        </FormItem>
        <FormItem label="上传图片：">
          <vue-uploadimg
            :imgUrl="imgUrl"
            :clear="clear"
            style="width: 400px"
            @uploadImg="uploadImg"
          ></vue-uploadimg>
          <!-- <el-upload
            ref="pictureUpload"
            action="https://upload-z2.qiniup.com/stage/file/uploadQiNiuFile"
            list-type="picture-card"
            :data="qiniuDataThree"
            :on-success="handleAvatarSuccessTree"

          >

            <i slot="default" class="el-icon-plus" />
            <div slot="file" slot-scope="{ file }">
              <img
                class="el-upload-list__item-thumbnail"
                :src="file.url"
                alt=""
              />
              <span class="el-upload-list__item-actions">
                <span
                  class="el-upload-list__item-delete"
                  @click="handleRemove(file)"
                >
                  <i class="el-icon-delete" />
                </span>
              </span>
            </div>
          </el-upload> -->
        </FormItem>
        <FormItem label="场馆简介：">
          <Input
            placeholder="请输入场馆简介"
            :rows="10"
            maxlength="5000"
            show-word-limit
            type="textarea"
            v-model="newData.about"
            clearable
            style="display: block"
          />
        </FormItem>
      </Form>
      <div slot="footer">
        <Button class="Button" type="warning" @click="modal = false"
          >关闭</Button
        >
        <Button
          class="Button"
          type="primary"
          @click="submit"
          :loading="loading2"
          >确认提交</Button
        >
      </div>
    </Modal>

    <!-- <Modal v-model="accountModal" :title="'开通试用账号 - '+museumTitle" width="50">
      <Form ref="form" :model="newData2" :label-width="100">
        <FormItem label="*账号：">
          <Input v-model="newData2.accountName" placeholder="请输入账号"></Input>
        </FormItem>
        <FormItem label="*密码：">
          <Input v-model="newData2.password" placeholder="请输入密码"></Input>
        </FormItem>
        <FormItem label="*姓名：">
          <Input v-model="newData2.realName" placeholder="请输入姓名"></Input>
        </FormItem>
        <FormItem label="手机号：">
          <Input v-model="newData2.phone" placeholder="请输入手机号"></Input>
        </FormItem>
      </Form>
      <div slot="footer">
        <Button class="Button" type="primary" @click="submit2" :loading="loading3">确认提交</Button>
      </div>
    </Modal> -->

    <Modal
      v-model="accountModal"
      :title="'查看管理员 - ' + museumTitle"
      width="70"
    >
      <Button type="primary" @click="create2">新增管理员</Button>
      <Table
        class="table"
        :loading="loading4"
        highlight-row
        :columns="columns2"
        :data="data3"
      />
      <div slot="footer"></div>
    </Modal>

    <Modal
      v-model="accountModal2"
      :title="'绑定管理员 - ' + museumTitle"
      width="50"
    >
      <label>
        <Input
          v-model="phone"
          @on-change="changePhone"
          suffix="ios-search"
          style="width: 100%"
          placeholder="请输入手机号"
        />
      </label>
      <Table
        height="400"
        class="table"
        :loading="loading6"
        highlight-row
        :columns="columns3"
        :data="userList"
      />
      <div slot="footer"></div>
    </Modal>
  </Card>
</template>

<script>
import { md5 } from '../config/md5.js'
import axios from 'axios'

export default {
  data () {
    return {
      // 上传图片需要的数据

      qiniuDataThree: {
        token: '',
        key: ''
      },
      loading1: false,
      loading2: false,
      loading3: false,
      loading4: false,
      loading5: false,
      loading6: false,
      // 场馆状态
      c_state: '',
      options: [
        {
          value: true,
          label: '已入驻'
        },
        {
          value: false,
          label: '未入驻'
        }
      ],
      // 预约方式
      reservationV: '',
      reservations: [
        {
          value: 1,
          label: '平台'
        },
        {
          value: 2,
          label: '小程序'
        },
        {
          value: 3,
          label: '网页'
        }
      ],
      data3: [],
      userId: '',
      usermuseumId: '',
      userList: [],
      phone: '',
      accountModal2: false,

      columns2: [
        {
          title: '管理员名称',
          key: 'name',
          align: 'center'
        },
        {
          title: '管理员手机',
          key: 'phone',
          align: 'center'
        },
        {
          title: '管理员ID',
          key: 'id',
          align: 'center'
        },
        {
          title: '操作',
          align: 'center',
          render: (h, params) => {
            return h('div', [
              h(
                'Button',
                {
                  props: {
                    type: 'primary'
                  },
                  on: {
                    click: () => {
                      this.cancel(params)
                    }
                  }
                },
                '解绑'
              )
            ])
          }
        }
      ],
      columns3: [
        {
          title: '管理员名称',
          key: 'name',
          align: 'center'
        },
        {
          title: '管理员手机',
          key: 'phone',
          align: 'center'
        },
        {
          title: '管理员ID',
          key: 'id',
          align: 'center'
        },
        {
          title: '操作',
          align: 'center',
          render: (h, params) => {
            return h('div', [
              h(
                'Button',
                {
                  props: {
                    type: 'primary'
                  },
                  on: {
                    click: () => {
                      this.chooseThis(params)
                    }
                  }
                },
                '添加此用户'
              )
            ])
          }
        }
      ],
      columns: [
        {
          title: '场馆名称',
          key: 'name',
          align: 'center'
        },
        // {
        //   title: "博物之声展示",
        //   align: "center",
        //   minWidth: 150,
        //   key: "online2",
        //   render: (h, params) => {
        //     const color = params.row.online2 == "开启" ? "primary" : "error";
        //     return h(
        //       "Tag",
        //       {
        //         props: { type: "dot", color: color }
        //       },
        //       params.row.online2
        //     );
        //   }
        // },
        // {
        //   title: "网上预约",
        //   align: "center",
        //   minWidth: 150,
        //   key: "openAppointment2",
        //   render: (h, params) => {
        //     const color =
        //       params.row.openAppointment2 == "开启" ? "primary" : "error";
        //     return h(
        //       "Tag",
        //       {
        //         props: { type: "dot", color: color }
        //       },
        //       params.row.openAppointment2
        //     );
        //   }
        // },
        // {
        //   title: "展览开放信息",
        //   key: "openingInformation",
        //   align: "center",
        //   minWidth: 300
        // },
        // {
        //   title: "博物馆缩略图",
        //   key: "pics2",
        //   align: "center",
        //   minWidth: 200,
        //   render: (h, params) => {
        //     return h(
        //       "div",
        //       {
        //         style: {
        //           padding: "5px 0"
        //         }
        //       },
        //       params.row.pics2.map(v => {
        //         return h("img", {
        //           style: {
        //             width: "50%",
        //             display: "block",
        //             marginLeft: "25%",
        //             marginTop: "5px"
        //           },
        //           attrs: {
        //             src: this.prefix + v
        //           }
        //         });
        //       })
        //     );
        //   }
        // },
        { title: '场馆位置', key: 'city', align: 'center' },
        {
          title: '场馆简介',
          key: 'about',
          align: 'center',

          render: (h, params) => {
            return h(
              'span',
              {
                style: {}
              },
              params.row.about
            )
          }
        },
        {
          title: '是否开启消息推送',
          key: 'about',
          align: 'center',

          render: (h, params) => {
            return h('i-switch', {
              props: {
                value: params.row.pushSwitch
              },
              on: {
                'on-change': () => {
                  this.enableOrDisablePushSwitch(params)
                }
              }
            })
          }
        },
        {
          title: '操作',
          align: 'center',
          render: (h, params) => {
            return h('div', [
              h(
                'Button',
                {
                  props: { type: 'warning' },
                  on: {
                    click: () => {
                      this.update(params)
                    }
                  }
                },
                '修改'
              ),
              h(
                'Button',
                {
                  props: {
                    type: 'success'
                  },
                  style: {
                    margin: '0 10px'
                  },
                  on: {
                    click: () => {
                      // this.account(params);
                      this.bangding(params)
                    }
                  }
                },
                '绑定管理员'
              ),
              h(
                'Button',
                {
                  props: {
                    type: 'error'
                  },
                  on: {
                    click: () => {
                      this.del(params)
                    }
                  }
                },
                '删除'
              )
            ])
          }
        }
      ],
      data1: [],
      current: 1,
      size: 10,
      total: 0,
      museumName: '',
      provinceCityId: '',
      provinceCityParentId: '',

      newData: {
        about: '',
        name: '',
        type: '',
        pics: [],
        provinceCityId: '',
        provinceCityParentId: '',
        online: false,
        openAppointment: false,
        openingInformation: '',
        arrivald1: '',
        arrivald2: '',
        arrivald3: ''
      },
      modal: false,

      data2: [],
      imgUrl: '',
      clear: false,
      cascaderValue: [],

      accountModal: false,
      newData2: {
        accountName: '',
        password: '',
        phone: '',
        realName: '',
        museumId: ''
      },
      museumTitle: '',
      // 小程序相关的 路径 以及 appid
      wxInfo: {
        appid: '',
        wxPath: ''
      },
      // 网页的链接
      h5Path: '',
      // 筛选的条件
      caption: {
        isSettle: '',
        jumpType: ''
      },
      // 场馆开放时间信息
      playTime: '',
      // 一个大概的详细地址
      dagai: '',
      // 详细地址的弹窗
      dialogVisible: false,
      // 详细地址的数据
      addreses: [],
      // 图片地址
      pic: '',
      // 很详细的地址的对象
      address: {
        detailAddress: '',
        latitude: '',
        longitude: '',
        name: ''
      }
    }
  },
  created () {
    this.cascadeProvinceCity()
    // 获取key
    // axios
    //   .get("http://test.bowu66.com:19309/stage/file/getFilePrefix")
    //   .then((res) => {
    //     this.qiniuDataThree.key = res.data.data;
    //   });
    // // 获取上传文件token
    // axios
    //   .get("http://test.bowu66.com:19309/stage/file/getAccessToken")
    //   .then((res) => {
    //     this.qiniuDataThree.token = res.data.data;
    //   });
  },
  methods: {
    // 删除图片

    handleRemove (file, fileList) {
      let uploadFiles = this.$refs.pictureUpload.uploadFiles
      for (var i = 0; i < uploadFiles.length; i++) {
        if (uploadFiles[i]['url'] == file.url) {
          uploadFiles.splice(i, 1)
        }
      }
    },
    // 获取图片地址
    handleAvatarSuccessTree (res) {
      console.log(res)
      this.pic = res.key
    },
    // 解绑管理员
    cancel (params) {
      console.log(params)
      this.$http('/stage/museum/unbindMuseumAdministrator', {
        museumId: this.usermuseumId,
        userId: params.row.id
      }, 'post', (res) => {
        if (res.data.code == 200 && res.data.data == true) {
          this.$Message.success('解绑成功')
          this.$http(
            '/stage/museum/getAdministratorByMuseumId',
            {
              museumId: this.usermuseumId
            },
            'get',
            (res) => {
              if (res.data.code == 200) {
                this.data3 = res.data.data
              } else {
                this.$Message.error(res.data.msg)
              }
            }
          )
        } else {
          console.log(res.data.msg);
          if (res.data.msg) {
            this.$Message.error(res.data.msg)
          } else {
            this.$Message.error('解绑失败')
          }
        }
      })
    },
    // 详细地址
    DetailedAddress () {
      this.$http(
        '/stage/museum/searchAddress',
        { keyword: this.dagai },
        'get',
        (res) => {
          this.addreses = res.data.data
        }
      )
    },
    cascadeProvinceCity () {
      this.loading1 = true

      this.$http('/stage/museum/cascadeProvinceCity', {}, 'post', (res) => {
        if (res.data.code == 200) {
          for (let i = 0; i < res.data.data.length; i++) {
            this.data2.push({
              value: res.data.data[i].id,
              label: res.data.data[i].name,
              children: []
            })
            for (let j = 0; j < res.data.data[i].cities.length; j++) {
              this.data2[i].children.push({
                value: res.data.data[i].cities[j].id,
                label: res.data.data[i].cities[j].name,
                children: []
              })
              for (
                let k = 0;
                k < res.data.data[i].cities[j].cities.length;
                k++
              ) {
                this.data2[i].children[j].children.push({
                  value: res.data.data[i].cities[j].cities[k].id,
                  label: res.data.data[i].cities[j].cities[k].name
                })
              }
            }
          }
          this.getAppMuseums()
        } else {
          this.$Message.error(res.data.msg)
          this.loading1 = false
        }
      })
    },
    getAppMuseums () {
      this.loading1 = true
      this.$http(
        '/stage/museum/getAppMuseums',
        {
          current: this.current,
          size: this.size,
          museumName: this.museumName,
          provinceCityId: this.provinceCityId,
          provinceCityParentId: this.provinceCityParentId,
          ...this.caption
        },
        'post',
        (res) => {
          if (res.data.code == 200) {
            this.data1 = res.data.data.records
            for (let i = 0; i < this.data1.length; i++) {
              for (let j = 0; j < this.data2.length; j++) {
                if (this.data1[i].provinceCityParentId == this.data2[j].value) {
                  for (let k = 0; k < this.data2[j].children.length; k++) {
                    if (
                      this.data1[i].provinceCityId ==
                      this.data2[j].children[k].value
                    ) {
                      for (
                        let l = 0;
                        l < this.data2[j].children[k].children.length;
                        l++
                      ) {
                        if (
                          this.data1[i].provinceDistrictId ==
                          this.data2[j].children[k].children[l].value
                        ) {
                          this.data1[i].city =
                            this.data2[j].label +
                            ' / ' +
                            this.data2[j].children[k].label +
                            ' / ' +
                            this.data2[j].children[k].children[l].label
                        }
                      }
                    }
                  }
                }
              }
            }

            this.total = res.data.data.total
          } else {
            this.$Message.error(res.data.msg)
          }
          this.loading1 = false
        }
      )
    },
    changePage (data) {
      this.current = data
      this.getAppMuseums()
    },
    create () {
      this.modal = true
      this.newData = {
        about: '',
        name: '',
        type: '',
        pics: [],
        provinceCityId: '',
        provinceCityParentId: '',
        online: false,
        openAppointment: false,
        openingInformation: ''
      }
      this.cascaderValue = []
      this.id = ''
      this.imgUrl = ''
      this.clear = !this.clear
    },
    update (params) {
      console.log(params.row)
      console.log(params.row.nature)
      this.modal = true
      this.id = params.row.id
      var arrival = params.row.arrivalPavilion.split('-')
      console.log(arrival)
      if (arrival.length == 2) {
        this.newData = {
          about: params.row.about,
          name: params.row.name,
          pics: [params.row.pics],
          online: params.row.online,
          latitude: params.row.latitude,
          longitude: params.row.longitude,
          openAppointment: params.row.openAppointment,
          openingInformation: params.row.openingInformation,
          type: params.row.typeMuseum,
          arrivalPavilion: params.row.arrivalPavilion,
          arrivald1: arrival[0],
          arrivald3: arrival[1]
        }
      } else if (arrival.length == 3) {
        this.newData = {
          about: params.row.about,
          name: params.row.name,
          pics: [params.row.pics],
          online: params.row.online,
          latitude: params.row.latitude,
          longitude: params.row.longitude,
          openAppointment: params.row.openAppointment,
          openingInformation: params.row.openingInformation,
          type: params.row.typeMuseum,
          arrivalPavilion: params.row.arrivalPavilion,
          arrivald1: arrival[0],
          arrivald2: arrival[1],
          arrivald3: arrival[2]
        }
      } else {
        this.newData = {
          about: params.row.about,
          name: params.row.name,
          pics: [params.row.pics],
          online: params.row.online,
          latitude: params.row.latitude,
          longitude: params.row.longitude,
          openAppointment: params.row.openAppointment,
          openingInformation: params.row.openingInformation,
          type: params.row.typeMuseum,
          arrivalPavilion: params.row.arrivalPavilion,
          arrivald1: '',
          arrivald2: '',
          arrivald3: ''
        }
      }

      console.log(this.reservationV)
      this.wxInfo = {
        appid: params.row.appId,
        wxPath: params.row.appletsPages
      }
      console.log(this.wxInfo)
      // h5的跳转
      this.playTime = params.row.openingInformation
      console.log(this.playTime)
      this.h5Path = params.row.appletsPages
      this.reservationV = params.row.jumpType
      this.address.detailAddress = params.row.address
      console.log(params.row)
      if (params.row.nature == 0) {
        this.c_state = true
      } else {
        this.c_state = false
      }
      if (params.row.provinceCityParentId == undefined) {
        this.cascaderValue = []
      } else {
        this.cascaderValue = [
          params.row.provinceCityParentId,
          params.row.provinceCityId,
          params.row.provinceDistrictId
        ]
      }
      if (params.row.pics == '') {
        this.imgUrl = ''
        this.clear = !this.clear
      } else {
        this.imgUrl = params.row.pics
      }
      console.log(this.imgUrl)
    },
    submit () {
      console.log(this.newData.type)
      if (this.newData.name == '') {
        this.$Message.error('场馆名称不能为空')
        return false
      }
      if (this.newData.type == '') {
        this.$Message.error('请选择场馆类型')
        return false
      }
      if (this.cascaderValue.length == 0) {
        this.$Message.error('请选择场馆所属城市')
        return false
      }
      if (this.newData.about == '') {
        this.$Message.error('场馆简介不能为空')
        return false
      }
      if (this.newData.arrivald1 == '') {
        this.$Message.error('请输入开馆时间')
        return false
      }
      if (this.newData.arrivald3 == '') {
        this.$Message.error('请输入闭馆时间')
        return false
      }
      if (this.newData.arrivald2 == undefined) {
        var ceshi = new Array(this.newData.arrivald1, this.newData.arrivald3)
        var ceshi2 = ceshi.join('-')
      } else {
        var ceshi = new Array(
          this.newData.arrivald1,
          this.newData.arrivald2,
          this.newData.arrivald3
        )
        var ceshi2 = ceshi.join('-')
      }
      console.log(ceshi2)

      this.loading2 = true
      var data = {}
      if (this.id == '') {
        console.log(this.address)
        data = {
          about: this.newData.about,
          address: this.address.detailAddress,
          latitude: this.address.latitude,
          longitude: this.address.longitude,
          isSettle: this.c_state,
          name: this.newData.name,
          pics: this.imgUrl,
          openingInformation: this.playTime,
          provinceCityId: this.cascaderValue[1],
          provinceCityParentId: this.cascaderValue[0],
          provinceDistrictId: this.cascaderValue[2],
          typeMuseum: this.newData.type,
          arrivalPavilion: ceshi2
        }
        // 小程序的跳转
        console.log(this.reservationV)
        console.log(data)
        if (this.reservationV == 2) {
          console.log(this.reservationV)
          data = {
            ...data,
            appId: this.wxInfo.appid,
            appletsPages: this.wxInfo.wxPath
          }
          console.log(data)
          // h5的跳转
        } else if (this.reservationV == 3) {
          data = { ...data, appletsPages: this.h5Path }
        }
        console.log(this.data)
        this.$http('/stage/museum/insertAppMuseum', data, 'post', (res) => {
          if (res.data.code == 200) {
            this.$Message.success('新增场馆成功')
            this.getAppMuseums()
            this.modal = false
          } else {
            this.$Message.error(res.data.msg)
          }
          this.loading2 = false
        })
      } else {
        if (this.address.latitude == '' || this.address.latitude == undefined) {
        } else {
          (this.newData.latitude = this.address.latitude),
          (this.newData.longitude = this.address.longitude)
        }
        data = {
          about: this.newData.about,
          name: this.newData.name,
          address: this.address.detailAddress,
          type: this.newData.type,
          typeMuseum: this.newData.type,
          openingInformation: this.playTime,
          provinceCityId: this.cascaderValue[1],
          latitude: this.newData.latitude,
          longitude: this.newData.longitude,
          provinceCityParentId: this.cascaderValue[0],
          provinceDistrictId: this.cascaderValue[2],
          id: this.id,
          pics: this.imgUrl,
          isSettle: this.c_state,
          arrivalPavilion: ceshi2
        }
        if (this.reservationV == 2) {
          console.log(this.reservationV)
          data = {
            ...data,
            appId: this.wxInfo.appid,
            appletsPages: this.wxInfo.wxPath
          }
          console.log(data)
          // h5的跳转
        } else if (this.reservationV == 3) {
          data = { ...data, appletsPages: this.h5Path }
        }
        console.log(data)
        this.$http('/stage/museum/updateMuseum', data, 'post', (res) => {
          if (res.data.code == 200) {
            this.$Message.success('修改场馆成功')
            this.getAppMuseums()
            this.modal = false
          } else {
            this.$Message.error(res.data.msg)
          }
          this.loading2 = false
        })
      }
    },
    uploadImg (data) {
      console.log(data)
      this.newData.pics[0] = data
      this.imgUrl = data
    },
    del (params) {
      this.$Modal.confirm({
        title: '提示',
        content:
          '<p>确定要删除场馆<strong> ' + params.row.name + ' </strong>吗？</p>',
        onOk: () => {
          this.loading1 = true
          this.$http(
            '/stage/museum/deleteMuseum',
            {
              id: params.row.id
            },
            'get',
            (res) => {
              if (res.data.code == 200) {
                this.$Message.success('删除场馆成功')
                this.current = 1
                this.loading1 = false
                this.getAppMuseums()
              } else {
                this.$Message.error(res.data.msg)
              }
            }
          )
        }
      })
    },
    account (params) {
      this.accountModal = true
      this.newData2 = {
        accountName: '',
        password: '',
        phone: '',
        realName: '',
        type: '',
        museumId: params.row.id
      }
      this.museumTitle = params.row.name
    },
    change (e) {
      this.current = 1
      this.getAppMuseums()
    },
    submit2 () {
      if (this.newData2.accountName == '') {
        this.$Message.error('账号不能为空')
        return false
      }
      if (this.newData2.password == '') {
        this.$Message.error('密码不能为空')
        return false
      }
      if (this.newData2.realName == '') {
        this.$Message.error('姓名不能为空')
        return false
      }
      this.loading3 = true
      this.$http(
        '/stage/user/createTryAccount',
        {
          accountName: this.newData2.accountName,
          museumId: this.newData2.museumId,
          password: md5(this.newData2.password),
          phone: this.newData2.phone,
          realName: this.newData2.realName
        },
        'post',
        (res) => {
          this.loading3 = false
          if (res.data.code == 200) {
            this.$Message.success('开通试用账号成功')
            this.accountModal = false
          } else {
            this.$Message.error(res.data.msg)
          }
        }
      )
    },
    change2 (e) {
      if (e.length == 0) {
        this.provinceCityId = ''
        this.provinceCityParentId = ''
      } else {
        this.provinceCityId = e[1]
        this.provinceCityParentId = e[0]
      }
      this.current = 1
      this.getAppMuseums()
    },
    bangding (params) {
      this.loading4 = true
      this.userId = ''
      this.museumTitle = params.row.name
      this.accountModal = true
      this.usermuseumId = params.row.id
      this.$http(
        '/stage/museum/getAdministratorByMuseumId',
        {
          museumId: params.row.id
        },
        'get',
        (res) => {
          if (res.data.code == 200) {
            this.data3 = res.data.data
          } else {
            this.$Message.error(res.data.msg)
          }
          this.loading4 = false
        }
      )
    },
    create2 () {
      this.accountModal2 = true
      this.phone = ''
      this.userList = []
    },
    chooseThis (params) {
      this.$Modal.confirm({
        title: '提示',
        content:
          '<p>确定要添加此用户<strong> ' +
          params.row.name +
          ' </strong>吗？</p>',
        onOk: () => {
          this.loading5 = true
          this.$http(
            '/stage/museum/bindMuseumAdministrator',
            {
              museumId: this.usermuseumId,
              userId: params.row.id
            },
            'post',
            (res) => {
              if (res.data.code == 200) {
                this.loading4 = true
                this.accountModal2 = false
                this.$http(
                  '/stage/museum/getAdministratorByMuseumId',
                  {
                    museumId: this.usermuseumId
                  },
                  'get',
                  (res) => {
                    if (res.data.code == 200) {
                      this.data3 = res.data.data
                    } else {
                      this.$Message.error(res.data.msg)
                    }
                    this.loading4 = false
                  }
                )
              } else {
                this.$Message.error(res.data.msg)
              }
              this.loading5 = false
            }
          )
        }
      })
    },
    changePhone () {
      this.loading6 = true
      this.$http(
        '/stage/museum/searchAppUserByPhone',
        {
          phone: this.phone
        },
        'get',
        (res) => {
          if (res.data.code == 200) {
            this.userList = res.data.data
          } else {
            this.$Message.error(res.data.msg)
          }
          this.loading6 = false
        }
      )
    },
    getCalendarStocks () {
      this.$http(
        '/stage/calendarTicket/getCalendarStocks',
        {
          museumId: this.usermuseumId,
          startDate: '',
          startEnd: ''
        },
        'get',
        (res) => {
          if (res.data.code == 200) {
            this.userList = res.data.data
          } else {
            this.$Message.error(res.data.msg)
          }
          this.loading6 = false
        }
      )
    },
    enableOrDisablePushSwitch (params) {
      console.log(params)
      this.$http(
        '/stage/museum/enableOrDisablePushSwitch',
        {
          mid: params.row.id
        },
        'get',
        (res) => {
          if (res.data.code == 200) {
          } else {
            this.$Message.error(res.data.msg)
          }
        }
      )
    }
  }
}
</script>

<style scoped>
.address-list {
  list-style: none;
}
.address-item {
  display: flex;
  align-content: center;
  justify-content: space-between;
}
.address-item {
  margin-bottom: 25px;
}
.address-item .name {
  width: 25%;
  color: black;
  font-size: 15px;
  font-weight: 600;
}
.address-item .detailAddress {
  width: 55%;
  font-size: 15px;
}
.text-overflow {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
</style>
